#include "dtr.h"
#include "rectype.h"
#include "util.h"
#include "cnfield.h"

#include "stdffield.h"
#include "stdffield.cpp"

using namespace std;
using namespace opsrc::stdf;

Dtr::Dtr()
{}

Dtr::Dtr(stdf_rec _stdfrec, int _reclen, std::ios::pos_type _fileRecFirstBytePosition, int _orderindex, endian e, char* buf)
    :RecBase(_stdfrec, _reclen, _fileRecFirstBytePosition, _orderindex),en(e) {
    if (buf!=0)
        readFields(buf);
}

Dtr::~Dtr() {
}


const StdfField<string> Dtr::getTextData() const {
    return text_dat;
}

void Dtr::setTextData(StdfField<string> textdat) {
    text_dat = textdat;
}

void Dtr::readFields(char *buf) {
#if _DEBUG
    cout << "stdfrec= DTR , filebytestartposition= " <<   getFileRecByteStartPosition() << ", databytecount= " << reclen <<endl;
#endif

    int curpos = 0;
    // Read text data number
    CnField<string> textdat(buf+curpos, en);
    text_dat.set(textdat.getData(), curpos, textdat.getByteCount(), textdat.getTotalByteCount());
}
